package AtmSystem;

import java.util.*;

public class BankAccountDB {

	private Vector<BankAccount> bankAccounts;

	public BankAccountDB ()
		{
		bankAccounts=new Vector();
		}

	public boolean add(BankAccount newBankAccount)
		{
			return bankAccounts.add(newBankAccount);
		}

	public boolean removeb(int newCardNumber)
		{
		BankAccount removedBankAccount =isExsit(newCardNumber);
		if(removedBankAccount != null)
			{
			bankAccounts.remove(removedBankAccount);
			return true;
			}
			return false;
		}

		public boolean remove(BankAccount newBankAccount)
		{
			return bankAccounts.remove(newBankAccount);
		}

		public BankAccount isExsit(int newCardNumber)
		{
			for(int index = 0;index<getNumbers();index ++)
			{
				if (bankAccounts.get(index).getCardNumber() == newCardNumber)
				{
					return (BankAccount) (bankAccounts.get(index) );
				}
			}
			return null;
		}

    	public int getNumbers()
		{
		return bankAccounts.size();
		}
		
		public BankAccount get(int index)
		{
			return bankAccounts.get(index);
		}
}
